/*
 *   Abstract Model class of MonteCarloApplication - single threaded & multi threaded
 */

package javaapplication6.MODEL;

import java.util.concurrent.ExecutionException;

/**
 * Abstract model used to differentiate the single and the multi threaded calculation
 * @author M
 */
public abstract class AbstractMonteCarloSimulation {
    protected String callPutFlag; // specify if the option is a call or a put
    
    protected double s,           // actual price
                   x,           // strike price
                   t,           // remaining time to option maturity
                   r,           // interest rate without risk
                   b,           // "frais"
                   v,           // price standard deviation
                   dt,          // T/nSteps
                   st,          // 
                   sum =0,         
                   drift,
                   vSqrt,
                   res;
    
    protected int nSteps,         // number of steps to calculate the price
                nSimulations,   // number of ways to explore
                i,
                j,
                z =0;
    
    protected long start, end; //Execution time use
    // To use for the benchmark
    protected final int numberOfCores = Runtime.getRuntime().availableProcessors();
    protected final double blockingCoefficient = 0.9;
    protected final int poolSize = (int)(numberOfCores / (1 - blockingCoefficient));
          
    /**
     * Simulation method
     * @param callPutFlag
     * @param s: share price of the day
     * @param x: strike price
     * @param t: Remaining time to option maturity
     * @param r: interest without risk
     * @param b: Carry rate cost of the option 
     * @param v: volatility
     * @param nSteps: number of intermediate points to calculate
     * @param nSimulations: number of way to explore
     * @return computed value of MonteCarlo, as an estimated price of the option
     * @throws java.lang.InterruptedException
     * @throws java.util.concurrent.ExecutionException
     */
    public abstract double MonteCarloStandardOption(String callPutFlag, double s, double x,
            double t, double r, double b,double v, int nSteps, int nSimulations) throws InterruptedException, ExecutionException;

    
    //GETTERS
    public long getStart() { return start;}
    public long getEnd() { return end;}
    public String getCallPutFlag() { return callPutFlag;}
    public double getS() { return s;}
    public double getX() { return x;}
    public double getT() { return t;}
    public double getR() { return r;}
    public double getB() { return b;}
    public double getV() { return v;}
    public double getDt(){ return dt;}
    public double getSt(){return st;}
    public double getSum() { return sum;}
    public double getDrift() { return drift;}
    public double getvSqrt() { return vSqrt;}
    public double getRes() { return res;}
    public int getnSteps() { return nSteps;}
    public int getnSimulations() { return nSimulations;}
    public int getI() { return i;}
    public int getJ() { return j;}
    public int getZ() { return z;}
    
    //SETTERS
    public void setCallPutFlag(String callPutFlag) { this.callPutFlag = callPutFlag;}
    public void setS(double s) { this.s = s;}
    public void setX(double x) { this.x = x;}
    public void setT(double t) { this.t = t;}
    public void setR(double r) { this.r = r;}
    public void setB(double b) { this.b = b;}
    public void setV(double v) { this.v = v;}
    public void setDt(double dt) { this.dt = dt;}
    public void setSt(double st) { this.st = st;}
    public void setSum(double sum) { this.sum = sum;}
    public void setDrift(double drift) { this.drift = drift;}
    public void setvSqrt(double vSqrt) { this.vSqrt = vSqrt;}
    public void setRes(double res) { this.res = res;}
    public void setnSteps(int nSteps) { this.nSteps = nSteps;}
    public void setnSimulations(int nSimulations) { this.nSimulations = nSimulations;}
    public void setI(int i) { this.i = i;}
    public void setJ(int j) { this.j = j;}
    public void setZ(int z) { this.z = z;}   
}
